package org.kevin.controller;

import org.kevin.bean.Employee;
import org.kevin.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: EmployeeController
 * @Description: TODO
 * @Author: kevin
 * @Date: 2019/8/23 16:40
 * @Version: 1.0
 */
@RestController
public class EmployeeController {

    @Autowired
    EmployeeService employeeService;

    @GetMapping("/getEmployee")
    public Employee getEmployee(Integer id) {
        Employee employee = employeeService.getEmp(id);
        return employee;
    }

    @GetMapping("/updateEmployee")
    public Employee update(Employee employee) {
        Employee emp = employeeService.udateEmp(employee);
        return emp;
    }

    @GetMapping("/deleteEmployee")
    public String deleteEmp(Integer id) {
        employeeService.deleteEmp(id);
        return "success";
    }

    @GetMapping("/emp/{lastName}")
    public Employee getEmployeeByLastName(@PathVariable("lastName") String lastName) {
        return employeeService.getEmployeeByLastName(lastName);
    }
}
